'use strict';

const path = require('path');
const _ = require('lodash');

const root = path.resolve(__dirname, '..');

const baseConfig = {
  app: {
    name: 'klg-logCollector',
    root: root,
    isProd: process.env.NODE_ENV === 'production',
    isDev: process.env.NODE_ENV === 'development',
    token: process.env.TOKEN || '123456',
    port: process.env.PORT || 9999
  },
  log: {
    dir: process.env.LOG_DIR || path.resolve(root, 'log')
  }
};

const platformConfig = {
  development: {
    app: {
      port: process.env.PORT || 9999,
      mongo: process.env.MONGO_URI || 'mongodb://localhost:27017/logCollector',
      rabbitmqUri: process.env.RABBITMQ_URI,
      logFile: process.env.LOG_FILE || true
    }
  },
  production: {
    app: {
      port: process.env.PORT || 9999,
      mongo: process.env.MONGO_URI || 'mongodb://localhost:27017/logCollector',
      rabbitmqUri: process.env.RABBITMQ_URI,
      logFile: process.env.LOG_FILE || false
    }
  }
};

module.exports = _.merge(baseConfig, platformConfig[process.env.NODE_ENV]);
